package net.wofly.right.service.impl;

import java.util.List;

import javax.transaction.Transactional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import net.wofly.right.domain.RegisterVerifyInfo;
import net.wofly.right.repository.RegisterVerifyInfoRepository;
import net.wofly.right.service.IRegisterVerifyInfoService;

@Service("iRegisterVerifyInfoService")
@Transactional
public class RegisterVerifyInfoServiceImpl implements IRegisterVerifyInfoService {

	@Autowired
	RegisterVerifyInfoRepository registerVerifyInfoRepository;

	@Override
	public RegisterVerifyInfo save(RegisterVerifyInfo entity) {
		return registerVerifyInfoRepository.save(entity);
	}

	@Override
	public void delete(RegisterVerifyInfo entity) {
		registerVerifyInfoRepository.delete(entity);
	}

	@Override
	public void delete(String key) {
		registerVerifyInfoRepository.delete(key);
	}

	@Override
	public RegisterVerifyInfo findOne(String key) {
		return registerVerifyInfoRepository.findOne(key);
	}

	@Override
	public List<RegisterVerifyInfo> save(List<RegisterVerifyInfo> entityList) {
		return (List<RegisterVerifyInfo>) registerVerifyInfoRepository.save(entityList);
	}
	
	@Override
	public List<RegisterVerifyInfo> findByRegisterAccountOrderByRegisterTimeDesc(String registerAccount) {
		return registerVerifyInfoRepository.findByRegisterAccountOrderByRegisterTimeDesc(registerAccount);
	}
	
	@Override
	public void deleteByInvalidTimeLessThan(Long currentMillis) {
		registerVerifyInfoRepository.deleteByInvalidTimeLessThan(currentMillis);
	}
}
